import api from "@/util/api.js";
async function findall(pageNo=1,pageSize=10,params={}){
    let p = Object.assign({}, params);

    let birthFrom, birthTo;//出生日期的开始和截止
    if (Array.isArray(p.birthdayR)) {
        if (p.birthdayR.length > 0) {
            birthFrom = p.birthdayR[0];
       
        }
        if (p.birthdayR.length > 1) {
            birthTo = p.birthdayR[1];
           
        }
        delete p.birthdayR;
       
    }
let resp=await api({
    url:"/user",
    method:"get",
    params:{
        pageNo,
        pageSize,
        ...p,
        birthFrom,
        birthTo
    }
});
return resp;
}
async function deletebyid(id){
let resp= await api({
    url:"/user",
    method:"delete",
    data:id
});
return resp;
}
function adduser(user){
let resp=api({
    url:"/user",
    method:"post",
    data:user
});
return resp;
}
function updateuser(user){
    let resp=api({
        url:"/user",
        method:"put",
        data:user
    });
    return resp;
    }



export {findall,deletebyid,adduser,updateuser}